/*
 *  Copyright (c) 2007 - 2009 Adobe
 *  All rights reserved.
 *
 *  Permission is hereby granted, free of charge, to any person obtaining
 *  a copy of this software and associated documentation files (the "Software"),
 *  to deal in the Software without restriction, including without limitation
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *  and/or sell copies of the Software, and to permit persons to whom the
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included
 *  in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 *  IN THE SOFTWARE.
 */
var adobeWindow = null;
var newWindow = null;

function openPopUpWindow(url, width, height, options, name) {
	if (window.opener != null) {
		/* load the content into a parent window. */
		window.opener.location = url;
		window.opener.focus();

	} else if (typeof (adobeWindow) != "undefined" && adobeWindow != null
			&& !(adobeWindow.closed)) {
		/*
		 * load the content into adobeWindow, since there is already an
		 * adobeWindow still open.
		 */
		adobeWindow.location = url;
		adobeWindow.focus();

	} else {
		/*
		 * open an adobeWindow, since there is no parent window or adobeWindow
		 * opened.
		 */
		if (!width)
			width = 714;
		if (!height)
			height = 536;
		if (!options)
			options = "menubar=no,toolbar=no,location=yes,status=no,resizable=yes,scrollbars=on";
		if (!name)
			name = "AdobeWindow";
		adobeWindow = window.open(url, name, "width=" + width + ",height="
				+ height + "," + options);
		adobeWindow.focus();
	}
}

function openNewWindow(url, w, h, options, name) { // v2.0

	if (typeof url == "undefined")
		return;
	var width = (typeof w == "undefined") ? "800" : w;
	var height = (typeof h == "undefined") ? "600" : h;
	if (!options)
		options = "scrollbars=no, resizeable=no";
	if (!name)
		name = "AdbeWin";

	newWindow = window.open(url, name, "width=" + width + ",height=" + height
			+ "," + options);
	newWindow.focus();
}
